<html>
<head>
<script type="text/javascript">
		var aJaxURL	= "server-side/report/filials.action.php";		//server side folder url
		var tName	= "report";		
		
		$(document).ready(function () {
			client()  ;  	
			LoadTable();   
			SetEvents("", "", "", tName, 'add-edit-form', aJaxURL);   				
		});
        
		function LoadTable(){
	//		var total = [9,10];
			/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum, Menu Array */
		    param = GetAjaxData({
		    	    start_m: $("#start_month").val(),
		    	    end_m  : $("#end_month").val(),
		    	    Year   : $("#Year").val(),
		    	    client : $("#myselect").val()			    	       
		    	    })
			  
			GetDataTable(tName, aJaxURL, "get_list", 9, param, 0, "", 1, "desc", [4,5,6,7]);

		    
		    chart_c= new Object();
		   	    
		    $.ajax({
            url: aJaxURL,
            async: false,
            data: param+"&act=" + "chart",
            success: function (data) { 
            	chart_c=data; 
             
            }
        }); 

		    console.log(chart_c)
		    $('#chart').highcharts({
		        chart: {
		            zoomType: 'xy'
		        },
		        title: {
		            text: '--'
		        },
		        xAxis: [{
		            categories: chart_c.xAxis,
		            crosshair: true
		        }] ,
		        yAxis: [{ // Secondary yAxis
		            title: {
		                text: '',
		                style: {
		                    color: Highcharts.getOptions().colors[0]
		                }
		            },
		            labels: {
		                format: '{value}',
		                style: {
		                    color: Highcharts.getOptions().colors[0]
		                }
		            },
		            opposite: true		            
		        },
		        { // Primary yAxis
			         //   labels: {
			            //    format: '{value}',
			            //    style: {
			                  //  color: Highcharts.getOptions().colors[1]
			           //     }
			         //   },
			            title: {
			               text: 'რეისები',
			              style: {
			                   color: Highcharts.getOptions().colors[1]
			                }
			            }
		        	
			        }], 
		        tooltip: {
		            shared: true
		        },
		        legend: {
		            layout: 'vertical',
		            align: 'left',
		            x: 120,
		            verticalAlign: 'top',
		            y: 100,
		            floating: true,
		            backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
		        },
		        series: [{
		            name: 'რეისები',
		            type: 'column',
		            yAxis: 1,
		            data: chart_c.series.data[0],		

		        }/* , {
		            name: 'საშუალო',
		            type: 'spline',
		            data: chart_c.series.data[1],
		
		        } */]
		    });
			
         }

	    $(document).on("change", ".inpt", function () {
	    	LoadTable();	    	
	    });

		function LoadDialog(form){
/* 			$.ajax({
                url: aJaxURL,
                data: "act=" + "client",
                success: function (data) {
                 if (typeof (data.error) != "undefined") {
                        if (data.error != "") {
                           // alert(data.error);
                        } else {
                        	$("#add-edit-form").html(data);
                        }
                    }
                }
            }); */
			 GetDialog("add-edit-form", "600");
			    param = GetAjaxData({
		    	    start_m: $("#start_month").val(),
		    	    end_m  : $("#end_month").val(),
		    	    Year   : $("#Year").val(),
		    	    client : $("#myselect").val(),
		    	    id     : rID			    	       
		    	    })
			 GetDataTable("inner_table", aJaxURL, "get_list1", 8, param, 0, "", 1, "desc", [4,5]);	

				 		
			    }

 		   function client(){
				$.ajax({
	                url: "server-side/report/r_Month.action.php",
	                data: "act=" + "client",
	                success: function (data) {
	                 if (typeof (data.error) != "undefined") {
	                        if (data.error != "") {
	                           // alert(data.error);
	                        } else {
	                        	$("#myselect").html(data.aaData);
	                        }
	                    }
	                }
	            });
			   } 
	    
</script>
<style>
table tr td:nth-child(11){
  	text-align: right;
  }
table tr td:nth-child(10){
  	text-align: right;
  }

</style>
</head>

<body>    
    <div id="dt_example" class="ex_highlight_row clear_box">
        <div id="container">
            <div id="dynamic">
            	<h2 align="center">პრინტერების ისტორია </h2>  
            	  <div id="button_area">
	            	<div class="left" style="width: 900px;">	           		
    	            	<select id='Year' class="inpt" style="display: inline-block;">
    	            	    <option value='0'>ყველა</option> 
    	            	    <option value='2015'>2015</option>
    	            	    <option value='2014'>2014</option>	            	   
    	            	</select> 	            	           		
                        <select  id="start_month" class="inpt" style="display: inline-block;">
							<option value="0">დან</option>
							<option value="01">იანვარი</option>
							<option value="02">თებერველი </option>
							<option value="03">მარტი</option>
 							<option value="04">აპრილი</option>
							<option value="05">მაისი </option>
							<option value="06">ივნისი</option>
							<option value="07">ივლისი</option>
							<option value="08">აგვისტო</option>
							<option value="09">სექტემბერი</option>
							<option value="10">ოქტომბერი</option>
							<option value="11">ნოემბერი</option>
							<option value="12">დეკემბერი</option>
						</select>
                        <select  id="end_month" class="inpt" style="display: inline-block;">
							<option value="">მდე</option>
							<option value="01">იანვარი</option>
							<option value="02">თებერველი </option>
							<option value="03">მარტი</option>
 							<option value="04">აპრილი</option>
							<option value="05">მაისი </option>
							<option value="06">ივნისი</option>
							<option value="07">ივლისი</option>
							<option value="08">აგვისტო</option>
							<option value="09">სექტემბერი</option>
							<option value="10">ოქტომბერი</option>
							<option value="11">ნოემბერი</option>
							<option value="12">დეკემბერი</option>
						</select>
						<select id='myselect' class="inpt" style="width: 200px; display: inline-block;"></select>
	            	</div>
            	</div>
        <table class="display" id="report">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 200px;">ქალაქი</th>  
                            <th style="width: 200px;">კლიენტი</th>
                            <th style="width: 200px;">ფილიალი</th>                        
                            <th style="width: 180px;">რეისების<br>რაოდენობა</th>                                                                              
                            <th style="width: 50px;">კარტრიჯი</th>
                            <th style="width: 50px;">პრინტერი</th>                            
                            <th style="width: 100%;">საშ. რაოდ</th>                                             
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                             <th>
                                <input type="text"  name="search_type" value="ფილტრი"  class="search_init"/>
                            </th>    
                            <th>
                                <input type="text" name="search_code" value="ფილტრი"  class="search_init"/>
                            </th>                            
                            <th>
                               <input type="text"  name="search_model" value="ფილტრი" class="search_init"/>                              
                            </th>
                            <th>
                               <input type="text"  name="search_letter" value="ფილტრი" class="search_init"/>
                            </th>     
                            <th>
                                <input type="text"  name="search_date" value="ფილტრი" class="search_init"/>
                            </th>
                            <th>
                                <input type="text"  name="search_client" value="ფილტრი" class="search_init"/>
                            </th>                         
                            <th>
                                <input type="text" name="search_work" value="ფილტრი" class="search_init"/>
                            </th>
                            <th>
                                <input type="text" name="search_work" value="ფილტრი" class="search_init"/>
                            </th>                                                                         
                            <th>
                            </th> 
                            <th>
                            </th>                                                                                  
                        </tr>
                    </thead>                       
                    <tfoot>
                        <tr>
     
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>  
                            <th>&nbsp;</th>                         
                            <th><p align="right">ჯამი:<br>სულ ჯამი:</p></th>
                            <th>&nbsp;</th> 
                            <th>&nbsp;</th>
                            <th>&nbsp;</th>
                            <th>&nbsp;</th> 
                        </tr>
                    </tfoot>
                </table>
            </div>
            <div class="spacer">
            </div>           
            
             <div id="chart" >
</div>
        </div>
       
    </div>
    <!-- jQuery Dialog -->
     <div id="add-edit-form" class="form-dialog" title="ბარათები">
    	<!-- aJax -->
	</div>   
</body>
</html>